A software template (which can be treated as a unit of source code), hereinafter called a ‘template’, is a known mechanism for reusing source code so that a software programmer can advantageously avoid rewriting or reconstructing subsequent occurrences of units of source code by using templates. Source code can include several source code files or can be a single source code file. Occurrences of a template can be found in a single source code file or in multiple source code files. A header file is usually used for defining a template. Templates are used with a computer programming language, such as C++ or ADA. However, it will be appreciated that in a generic sense a unit or source code can be repeated used in source code written in a computer programming language, such as an object oriented programming language or a structured programming language. It will be appreciated that a template can be referred by many other names, such as a “generic” in the parlance of the ADA programming language.
Referring to FIG. 1, there is depicted a compilation environment 100 for compiling a single source code file 102 having multiple occurrences of templates 104A, 104B, and 104C. A compiler 106 reads source code file 102 to generate an object code file 108 corresponding to source code file 102. Hereinafter, for the purposes of simplifying the description, the term “object code ‘of’ source code” will mean “object code ‘corresponding to’ source code”. Object file 108 includes multiple occurrences of object code 110A, 110B, 110C corresponding to the multiple occurrences of templates 104A, 104B, 104C respectively. The manner in which compiler 106 operates is not adequate because compilation time was used for generating identical occurrences object code 110A, 110B, and 110C each corresponding to the same identical template, and storage space was used to store multiple occurrences of identical object code which is disadvantageously wasteful.
Generally, the prior art provides an inadequate method for compiling many source code files each having multiple occurrences of a template. Compilation time is wasted compiling the multiple occurrences of the template to generate many object code files each having multiple occurrences of identical object code of the template. In addition, the resulting generated object code files will be linked to create a bloated executable file due to the presence of the multiple occurrences of identical object code. Therefore, larger amounts of memory storage medium will be required to store the generated executable file.
Accordingly, a compiler which addresses, at least in part, these and other shortcomings is desired.